#!/bin/bash

# Test format cluster just after sheeps start up

. ./common

for i in `seq 0 7`; do
    _start_sheep $i
done

while true; do
    $DOG cluster format 2> /dev/null
    if [ $? == 0 ]; then
        break
    fi
    # try again until at least one sheep starts up
done &

pid=$!

for cnt in `seq 60`; do # wait at most 60 seconds
    jobs 1 > /dev/null 2>&1
    if [ $? != 0 ]; then
	break
    fi
    sleep 1
done
kill $pid > /dev/null 2>&1

_wait_for_sheep 8

for i in `seq 0 7`; do
    $DOG cluster info -p 700$i | head -1
    $DOG node list -p 700$i
done
